package com.hup.minicontroller.common.bluetooth.model;

import com.hup.minicontroller.common.bluetooth.BtConstant.BtDataType;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * {@link BtDataType#LOGIN_RESPONSE}
 * 和 {@link BtLoginRequestPacket} 不一样,本类有failure方法,需要被实例化,所以不能定义成接口
 *
 * @author hugan
 * @date 2021/5/1
 */
@ToString
public class BtLoginResponsePacket implements BaseBtDataPacket {

    @Setter
    @Getter
    private boolean success = true;

    @Setter
    @Getter
    private String errorMessage;

    @Override
    public int getType() {
        return BtDataType.LOGIN_RESPONSE;
    }

    public static BtLoginResponsePacket failure(String msg) {
        BtLoginResponsePacket res = new BtLoginResponsePacket();
        res.success = false;
        res.errorMessage = msg;
        return res;
    }

}
